
(function(){
    let url = location.href
    console.log(url);
    let urlObj = getQueryString(url)
    fetch('http://chst.vip:1234/api/getbrand?brandtitleid=' + urlObj.brandtitleid)
    .then(response => {
        return response.json()
    }).then(res => {
        console.log(res);
        let data = res.result[0];
        console.log(data);

        $('#subNav a').eq(2).html(data.brandName + '&gt;')
    })
})();


// 渲染分页列表
(function(){
    let url = location.href
    // console.log(url);
    let urlObj = getQueryString(url)

    // 定义渲染页面函数
    function render(){
        fetch(`http://chst.vip:1234/api/getbrandproductlist?brandtitleid=${urlObj.brandtitleid}`)
        .then(response => {
            return response.json()
        }).then(res => {
            let data = res.result;
            console.log(data);
    
            let ele = ''
            data.forEach(item => {
                ele += `
                <li>
                    <a href="productlist.html?categoryid=${urlObj.brandtitleid}&productid=${item.productId}">
                        <div class="img">
                            ${item.productImg}
                        </div>
                        <div class="infor">
                            <div class="title">
                                <h4>${item.productName}</h4>
                            </div>
                            <div class="price">${item.productPrice}</div>
                            <div class="other">
                                <div class="take_price">${item.productQuote}</div>
                                <i class="iconfont icon-xiaoxi"></i>
                                <span>${item.productCom}</span>
                            </div>
                        </div>
                    </a>
                </li>
                `
            });
    
            $('.info').html(ele)
        })
    };

    // 调用函数
    render()

})();